<template>
  <div>
    <MyVanskeleton :row="5" :loading="loading">
      <template v-slot:my-content>
        <div>
					<!-- share, hide for check of huawei -->
          <!-- <NavShareBar :title="title" :onShare="onShare" /> -->
					<van-nav-bar  :title="title" fixed left-arrow @click-left="$router.back()"  />
          <!-- 详情 start -->
          <div class="news-info content-top">
            <div class="title">
              <b>{{ data.title }}</b>
            </div>
            <div class="data">
              <span>
                <van-icon name="clock-o" size="13" color="#aaa" />{{$dayjs(data.datetime).format("MM-DD")}}
              </span>
              <span>
                <van-icon name="eye-o" size="13" color="#aaa" />{{ data.times }}
              </span>
            </div>
            <div class="details" v-html="data.content"></div>
          </div>
          <!-- 详情 end -->
        </div>
      </template>
    </MyVanskeleton>
  </div>
</template>

<script>
import { NavBar } from "vant";
import MyVanskeleton from "@/components/MyVanskeleton.vue";
import NavShareBar from "@/components/NavShareBar.vue";
import { Icon } from "vant";
import { returnToPhoneWithData } from "@/util/phone";
import Global from "@/Global";
export default {
  name: "NewsInfo",
  components: {
		[NavBar.name]: NavBar,
    NavShareBar,
    MyVanskeleton,
    [Icon.name]: Icon,
  },
  // 定义属性
  data() {
    return {
      title: "资讯详情",
      loading: true,
      news_id: 0,
      data: {},
    };
  },
  mounted() {
    this.news_id = this.$route.query.news_id;
    this.onLoad();
  },
  // 方法集合
  methods: {
    async onLoad() {
      this.$api.get('/Wap/GetNewsInfo', { newsId: this.news_id }).then(res => {
        this.loading = false;
        if (res.success) {
          this.data = res.response;
          this.title = res.response.title;
        }
      })
    },
    onShare() {
      console.log(this.data);
      let title = this.data.title;
      let content = "";
      if (this.data.type === 2) {
        content = "最新政策资讯、活动通知，就上舟山人才网（93job.com）";
      } else {
        content = "嘉兴最新、最热的即时招聘，就上舟山人才网（93job.com）";
      }
      returnToPhoneWithData({
        action: "share",
        title,
        content,
        url:
          Global.share_person_url +
          `/Index/ShowArticle.aspx?NewsID=${this.news_id}`,
      });
    },
  },
};
</script>

<style lang="less" scoped>
@import "./news.css";
</style>
